//
//  TuangouController.m
//  ELife
//
//  Created by 丰 璐 on 11-8-2.
//  Copyright 2011年 __MyCompanyName__. All rights reserved.
//

#import "TuangouController.h"
#import "ELifeAppDelegate.h"

@implementation TuangouController
@synthesize webView;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)dealloc
{
    [webView release];
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    UIBarButtonItem *temporaryRightButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"返回" 
                                                                                 style:UIBarButtonItemStyleBordered  
                                                                                target:self action:@selector(cancelAction)];
    self.navigationItem.leftBarButtonItem = temporaryRightButtonItem;
    [temporaryRightButtonItem release];
    
    finishBool = NO;
//    [webView setUserInteractionEnabled:NO];
    [webView setBackgroundColor:[UIColor clearColor]];
    [webView setDelegate:self];
    [webView setOpaque:NO];//使网页透明
    
    NSString *path = [[[ELifeAppDelegate App] tuangou] objectAtIndex:1];
    NSURL *url = [NSURL URLWithString:path];
    [webView loadRequest:[NSURLRequest requestWithURL:url]];
    // Do any additional setup after loading the view from its nib.
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

-(void) cancelAction
{
    [self.parentViewController dismissModalViewControllerAnimated:YES];
}

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
//    if (finishBool) {
//        [webView loadRequest:request];
//    }
    
    return YES;
}
- (void)webViewDidStartLoad:(UIWebView *)webView
{

}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{

}
@end
